package com.sh.data.engine.domain.shims.opentsdb.util;

import com.alibaba.fastjson.JSONObject;
import com.sh.data.engine.common.util.HttpClientUtil;
import org.springframework.util.StringUtils;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/12 14:24
 */
public class OpenTSDBUtil {

    public static boolean testConnection(String dsLink) {
        boolean isSuccess = false;

        dsLink = dsLink + "/api/version";

        String message = HttpClientUtil.doGet(dsLink, 4000);
        if (!StringUtils.isEmpty(message)) {
            JSONObject json = JSONObject.parseObject(message);
            if (!StringUtils.isEmpty(json.getString("version"))) {
                isSuccess = true;
            }
        }
        return isSuccess;
    }
}
